import * as THREE from 'three'
import { SimplifyModifier } from 'three/examples/jsm/modifiers/SimplifyModifier'
import earth_cw from '@/assets/images/earth/earth-cw.jpg'
const modifier = new SimplifyModifier()

// 地球
export let infoBallTexTure = null
export const infoBall = (threeInfo) => {
  let { radius, group, scene } = threeInfo
  // 纹理贴图
  const world_img1 = earth_cw
  let textureLoader = new THREE.TextureLoader()
  infoBallTexTure = textureLoader.load(world_img1, function (texture) {
    // 创建球
    let geometry = new THREE.SphereGeometry(radius, 100, 100)
    const simplifiedGeometry = modifier.modify(geometry, 0.5) // 50% 的面数

    let material = new THREE.MeshBasicMaterial({
      map: texture, //设置颜色贴图属性值
    })
    //网格模型对象Mesh
    let mesh = new THREE.Mesh(simplifiedGeometry, material)
    // 唯一标识
    mesh.name = '地球'
    // 添加到场景中
    group.add(mesh)
    scene.add(group)
  })
}
